package org.niux.aims.action;

import java.io.File;

import javax.annotation.Resource;

import org.apache.struts2.ServletActionContext;
import org.niux.aims.common.util.FileUtil;
import org.niux.aims.common.web.AimsBaseAction;
import org.niux.aims.service.ILogsService;
import org.niux.aims.vo.AccountVO;

/**
 * 
 * Copyright (c) 2013,niux<br>
 * All rights reserved.<br>
 * 
 * 文件名称：DataBackUpAction.java<br>
 * 摘    要：数据备份ACTION类<br>
 * <br>
 * 当前版本：<br>
 * 作    者：梁铭显 Email: <a href="mailto:liangmingxian@gmail.com">liangmingxian@gmail.com</a><br>
 * 完成日期：2013-9-24<br>
 * <br>
 * 取代版本：<br>
 * 原作者  ：<br>
 * 完成日期：2013-9-24<br>
 */
public class DataBackUpAction extends AimsBaseAction {

	/**
	 * 
	 */
	private static final long serialVersionUID = -7686318608881872094L;
	private int backupCount;
	
	@Resource(name="logsService")
	private ILogsService logsService;
	
	/**
	 * 
	 * 方法概述：页面渲染
	 * 描述：页面渲染
	 * @return
	 * 返回类型：String
	 * 修改人：梁铭显 
	 * 修改时间：2013-9-24
	 */
	public String showPage(){
		logsService.addLog("【"+((AccountVO)super.getSession().get("account")).getName()+"】进入数据备份界面");
		FileUtil fileUtil = new FileUtil();
		String path = ServletActionContext.getServletContext().getRealPath("backup");
		File[] fileList = fileUtil.getFileList(path);
		backupCount = (fileList == null ? 0 : fileList.length);
		
		return SUCCESS;
	}

	public int getBackupCount() {
		return backupCount;
	}

	public void setBackupCount(int backupCount) {
		this.backupCount = backupCount;
	}
}
